/*
 * Project: a2
 * Copyright (C) 2008 ralfoide gmail com,
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.alfray.a2;

import android.content.Intent;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;

/**
 * Displays preferences
 */
public class PrefsActivity extends PreferenceActivity {

	public static final String EXTRA_ENABLE_VISUALS = "enable-visuals";

    @Override
	protected void onCreate(Bundle savedInstanceState) {

        // Have the system blur any windows behind this one -- this is
        // used only with the TransparentTheme, which we don't currently use.
        // getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
        //        WindowManager.LayoutParams.FLAG_BLUR_BEHIND);

		super.onCreate(savedInstanceState);

		Intent intent = getIntent();
		boolean enable_themes = intent.getBooleanExtra(EXTRA_ENABLE_VISUALS, true);

		setTitle(R.string.prefs_title);
		addPreferencesFromResource(R.xml.prefs);

	    Preference p = getPreferenceScreen().findPreference(PrefsValues.KEY_VISUAL);
	    if (p != null) {
	        p.setEnabled(enable_themes);
	        if (!enable_themes) {
	            PrefsValues values = new PrefsValues();
	            values.update(this);
	            p.setTitle(p.getTitle() + ": " + values.getVisualTheme());
	            p.setSummary("The current visual theme for sprites cannot be changed during a game.");
	        }
	    }

        // This is used only with the TransparentTheme, which we don't currently use.
	    // getListView().setBackgroundResource(R.drawable.transp_grey);
        // getListView().setCacheColorHint(0x80808080);
	}
}
